define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
    $scope.form.id = params.id;

    httpService.post(app.urls.rule_selectIcon,{},function(data){
		if("0000" === data.code){
			$scope.icons = data.data;
		}else{
			alert(data.msg);
		}
	});
	httpService.post(app.urls.button_selectById, $scope.form, function(data) {
		if("0000" === data.code){
			$scope.form = data.data;
		}else{
			alert(data.msg);
		}
	});

	//删除按钮
	$scope.remove = function() {
		eventBusService.publish("modal.alert",{"content":"你是否确认删除这条数据？","isAutoClose":false,"confirm":function() {
			httpService.post(app.urls.button_delete, $scope.form, function(data) {
				if("0000" === data.code) {
					eventBusService.publish("content.button.reload",data.data);
					eventBusService.publish("modal.page.close",{});
	    		}else{
	    			alert(data.msg);
	    		}
			});
		},"cancel":function(){
			//用户取消，不做操作
		}});
	}

	$scope.save = function() {
		if($scope.formCheck()) {
			httpService.post(app.urls.button_update, $scope.form, function(data) {
				if("0000" === data.code) {
					eventBusService.publish("content.button.reload",data.data);
					eventBusService.publish("modal.page.close",{});
	    		}else{
	    			alert(data.msg);
	    		}
			});
		}
		
	}
	
            
}}});